﻿import { errorTips } from './utils';
import $config from '@/config';

export default function httpErrorHandle(code: number) {
    switch (code) {
        case 400:
            errorTips('错误的请求');
            break;
        case 401:
            showDialog({
                title: '提示',
                message: '未鉴权，请重新登录',
                confirmButtonText: '确认',
            }).then(() => {
                location.href = $config.ORIGIN + '/login';
            });
            break;
        case 403:
            showDialog({
                title: '提示',
                message: '未鉴权财，请重新登录',
                confirmButtonText: '确认',
            }).then(() => {
                location.href = $config.ORIGIN + '/login';
            });
            break;
        case 404:
            errorTips('请求地址不存');
            break;
        case 500:
            errorTips('服务器错误，请稍后再试');
            break;
        default:
            errorTips('服务器错误，请稍后再试');
            break;
    }
}
